                            <? $frmtime = time(); ?>
                            <div class="main">
                                <h3 class="title"><?=$clabel?> &raquo; <?=$mlabel?></h3>
                                <div class="formdiv">
                                    <form method="POST" id="frmEditStudent<?=$frmtime?>">
                                        <table class="detail">                                            
                                            <? if( isset($errors) && is_array($errors) ) {
                                               foreach($errors as $error) {
                                               ?>
                                            <tr>
                                                <td class="errormsg" colspan="3">
                                                    <?=$error?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <? if( isset($successes) ) {
                                               foreach($successes as $success) {
                                               ?>
                                            <tr>
                                                <td class="successmsg" colspan="3">
                                                    <?=$success?>    
                                                </td>
                                            </tr>   
                                               <? 
                                               } 
                                            }  ?>
                                            <tr>
                                                <td colspan="3">
                                                    <h2><?=$student_name?></h2>    
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_name">Name</label></td>
                                                <td width="300px">
                                                    <?=$student_name?>
                                                </td>
                                                <td rowspan="6" width="150px">
                                                    <div id="dci<?=$frmtime?>" class="divpimg">
                                                        <?
                                                            $imgsrc = "/images/no-img.jpg";
                                                            if($student_image!="") {
                                                                $imgsrc = $student_image."?t=".$frmtime;
                                                        ?>
                                                            
                                                        <?
                                                            }
                                                        ?>
                                                        <img id="imgProf<?=$frmtime?>" src="<?=$imgsrc?>" />
                                                        <div id="addimage_<?=$reg_no?>" regno="<?=$reg_no?>" class="divaddimg">
                                                            <span><a href="#divImgEdit<?=$frmtime?>">Add/Change Image</a></span>
                                                        </div>
                                                        <div style="display: none;">
                                                            <div id="divImgEdit<?=$frmtime?>" class="diveditimg">
                                                                    <h3 class="title">Add or Change Profile Image</h3>
                                                                    <input type="hidden" name="img_reg_no" value="<?=$reg_no?>"/>
                                                                    <input id="file_upload<?=$frmtime?>" type="file" name="file_upload_reg_no" />
                                                                    <div>
                                                                        <input type="button" name="btnUpload" id="btn_file_upload<?=$frmtime?>" class="button" value="Upload" style="margin-top: 5px;"/>
                                                                    </div>
                                                                    <div id="divprofileimg<?=$frmtime?>" style="margin-top: 40px; min-width: 450px;">
                                                                        
                                                                    </div>
                                                                    <div id="divEditProfileImg<?=$frmtime?>" style="float: right; position: absolute; bottom: 25px; right: 5px;">
                                                                        <form id="frmEditProfileImg<?=$frmtime?>">
                                                                            <input type="hidden" name="profile_reg_no" value="<?=$reg_no?>"/>
                                                                            <input type="hidden" id="img<?=$frmtime?>" name="img"/>
                                                                            <input type="hidden" id="x<?=$frmtime?>" name="x" />
                                                                            <input type="hidden" id="y<?=$frmtime?>" name="y" />
                                                                            <input type="hidden" id="w<?=$frmtime?>" name="w" />
                                                                            <input type="hidden" id="h<?=$frmtime?>" name="h" />
                                                                            <input class="button" id="btnCrop<?=$frmtime?>" type="button" value="Crop & Save" />
                                                                        </form>
                                                                    </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <script type="text/javascript" language="javascript">
                                                        function updateCoords(c) {
                                                            $('#x<?=$frmtime?>').val(c.x);
                                                    		$('#y<?=$frmtime?>').val(c.y);
                                                    		$('#w<?=$frmtime?>').val(c.w);
                                                    		$('#h<?=$frmtime?>').val(c.h);
                                                            //console.log("Co-ordinates updated");
                                                        }
                                                        $(document).ready( function() {
                                                            $("#dci<?=$frmtime?>").mouseenter(function(event){
                                                               $("#dci<?=$frmtime?> .divaddimg").addClass('active');
                                                            }).mouseleave(function(event){
                                                               $("#dci<?=$frmtime?> .divaddimg").removeClass('active');
                                                            });
                                                            $("#btn_file_upload<?=$frmtime?>").click(function(){
                                                                //console.log("Upload started");
                                                                $('#file_upload<?=$frmtime?>').uploadifyUpload();
                                                            });
                                                            $("#btnCrop<?=$frmtime?>").click(function() {
                                                                if($('#img<?=$frmtime?>').val()=="") {
                                                                    alert("Select & upload an Image first.")
                                                                } else {
                                                                    var ip = $("#divEditProfileImg<?=$frmtime?> :input");
                                                                    var params = ip.serialize();
                                                                    
                                                                    
                                                                   var jqxhr = $.post(
                                                                        "/student/cropimage", 
                                                                        params, 
                                                                        function (data) {
                                                                            var objResult = $.parseJSON(data);
                                                                            $("#divprofileimg<?=$frmtime?>").html("<img src='"+objResult.data.src+"' />");
                                                                            $("#imgProf<?=$frmtime?>").attr("src",objResult.data.src+"?t="+(new Date().getTime() / 1000));
                                                                            $.fancybox.close();
                                                                        }
                                                                    );
                                                                }
                                                            });
                                                            $("#file_upload<?=$frmtime?>").uploadify({
                                                                'fileExt'   : '*.jpg',
                                                                'fileDesc'  : 'Image Files (JPG)',
                                                                'uploader'  : '/uploadify/uploadify.swf',
                                                                'script'    : '/student/uploadimage',
                                                                'cancelImg' : '/uploadify/cancel.png',
                                                                'folder'    : '/uploads',
                                                                'sizeLimit' : 2000000,
                                                                onComplete  : function(event, ID, fileObj, response, data) {
                                                                    var objResult = $.parseJSON(response);
                                                                    $("#divprofileimg<?=$frmtime?>").html("<img src='"+objResult.data.src+"' />");
                                                                    $('#img<?=$frmtime?>').val(objResult.data.src);
                                                                    $("#divprofileimg<?=$frmtime?> img").Jcrop({
                                                                        aspectRatio: 150 / 188,
                                                                        minSize: [150, 188],
                                                                        setSelect:  [0,0, 150, 188],
                                                                        onSelect:   updateCoords
                                                                    });
                                                                },
                                                                'onError'     : function (event,ID,fileObj,errorObj) {
                                                                    //console.log(errorObj.type + ' Error: ' + errorObj.info);
                                                                }
                                                              });
                                                              
                                                            $("#dci<?=$frmtime?> #addimage_<?=$reg_no?>").click(function() {
                                                                var reg_no = jQuery(this).attr("regno");
                                                                $.fancybox({
                                                        			'padding'		: 0,
                                                                    'href'          : "#divImgEdit<?=$frmtime?>",
                                                                    'autoScale'     : true,
                                                                    'onComplete'    : function() {
                                                                        var img_src = $("#imgProf<?=$frmtime?>").attr("src");
                                                                        
                                                                        if(img_src!="/images/no-img.jpg") {
                                                                            $("#divprofileimg<?=$frmtime?>").html("<img src='"+img_src+"' />");
                                                                            img_src = img_src.substring(img_src.indexOf('/'),img_src.indexOf('?'));
                                                                            $('#img<?=$frmtime?>').val(img_src);
                                                                            $("#divprofileimg<?=$frmtime?> img").Jcrop({
                                                                                aspectRatio: 150 / 188,
                                                                                minSize: [150, 188],
                                                                                setSelect:  [0,0, 150, 188],
                                                                                onSelect:   updateCoords
                                                                            });
                                                                        }
                                                                    }
                                                        		});
                                                            });
                                                        });
                                                    </script>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_name">Reg. No.</label></td>
                                                <td>
                                                    <?=$reg_no?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_name">Reg. Date</label></td>
                                                <td>
                                                    <?=$reg_date?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_joining_date">Joining Date</label></td>
                                                <td>
                                                    <?=$student_joining_date?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_status">Status</label></td>
                                                <td>
                                                    <?=$student_status_text?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_class">Class</label></td>
                                                <td>
                                                    <?=$class_label?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_division">Division</label></td>
                                                <td colspan="2">
                                                    <?=$division_label?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label>Gender</label></td>
                                                <td colspan="2">
                                                    <? if($student_gender == 'm') echo "Male"; else echo "Female"; ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_dob">Date Of Birth</label></td>
                                                <td colspan="2">
                                                    <?=$student_dob?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_nationality">Nationality</label></td>
                                                <td colspan="2">
                                                    <?=$name?>
                                                </td>
                                            </tr>                                            
                                            <tr>
                                                <td><label for="student_rp_no">RP No.</label></td>
                                                <td colspan="2">
                                                    <?=$student_rp_no?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_rp_expiry">RP Expiry</label></td>
                                                <td colspan="2">
                                                    <?=$student_rp_expiry?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_father_name">Father&#39;s Name</label></td>
                                                <td colspan="2">
                                                    <?=$student_father_name?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_father_rp_no">Father&#39;s RP No.</label></td>
                                                <td colspan="2">
                                                    <?=$student_father_rp_no?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_mother_name">Mother&#39;s Name</label></td>
                                                <td colspan="2">
                                                    <?=$student_mother_name?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_res_area">Area</label></td>
                                                <td colspan="2">
                                                    <?=$area_name?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_address">Address</label></td>
                                                <td colspan="2" height="140px">
                                                    <?=$student_address?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_phone_mob">Mobile</label></td>
                                                <td colspan="2">
                                                    <?=$student_phone_mob?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_phone_office">Telephone (Office)</label></td>
                                                <td colspan="2">
                                                    <?=$student_phone_office?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_phone_res">Telephone (Residence)</label></td>
                                                <td colspan="2">
                                                    <?=$student_phone_res?>
                                                </td>
                                            </tr>                                            
                                            <tr>
                                                <td><label for="student_email">Email</label></td>
                                                <td colspan="2">
                                                    <?=$student_email?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_father_workplace">Father&#39;s Work Place</label></td>
                                                <td colspan="2" height="140px">
                                                    <?=$student_father_workplace?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label>Left Handed</label></td>
                                                <td colspan="2">
                                                    <? if($student_left_handed == '1') echo "Yes"; else echo "No"; ?>    
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_allergy">Allergies if any</label></td>
                                                <td colspan="2" height="140px">
                                                    <?=$student_allergy?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_leaving_date">Date of Leaving</label></td>
                                                <td colspan="2">
                                                    <?=$student_leaving_date?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_leaving_reason">Reason for Leaving</label></td>
                                                <td colspan="2" height="140px">
                                                    <?=$student_leaving_reason?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label for="student_comment">Comments</label></td>
                                                <td colspan="2" height="140px">
                                                    <?=$student_comment?>
                                                </td>
                                            </tr>
                                        	<tr>
                                        		<td></td>
                                        		<td colspan="2">
                                                    <input type="hidden" name="reg_no" value="<?=$reg_no?>"/>
                                                    <input class="button" type="submit" name="btnEditStudent" value="Edit" id="btnEditStudent" />
                                                </td>
                                        	</tr>
                                        </table>
                                	</form>
                                    <script language="javascript" type="text/javascript">
                                        if(typeof jQuery == 'undefined') {
                                            alert('Invalid Request');
                                            window.location = "/";
                                        }
                                        $(document).ready( function() {
                                            $("#frmEditStudent<?=$frmtime?>").validate({
                                                errorPlacement: function(error, element) {
                                                    placeError(error, element);
                                                },
                                                submitHandler: function(form) {
                                                    var cui = $('#contenttabs .ui-tabs-panel:visible');                                                                                                        
                                               	    var jqxhr = $.post(
                                                        "/student/editstudent", 
                                                        $("#frmEditStudent<?=$frmtime?>").serialize(), 
                                                        function (data) {
                                                            $(cui).html(data);
                                                        }
                                                    );
                                                    $(cui).html('<div id="loadingdiv"><div class="centerdiv"><strong>Processing</strong><br/><img src="/images/ajaxloader.gif" /></div></div>');
                                                }
                                            });
                                        });
                                    </script>
                                 </div>
                            </div>